#!/bin/bash

# if [ -z "$1" ]; then
	# echo 'summ.sh [-s sample_name] <input.bam> <interval.bed>'
	# exit 1
# fi
tools_path=/mnt/ilustre/app/medical/tools

source ${tools_path}/.var

log=.log
if [ ! -e "$log" ]; then
	:> $log
fi


depth=1.depth.txt
depth0=depth.txt


m_path=${tools_path}/matlab

if [ `pwd` != $m_path ]; then
	cp $m_path/plot_depth.m  . 2>>$log
fi


awk '{print $6}' $depth > $depth0 2>>$log

$matlab -nosplash -r "plot_depth; quit;" 2>>$log

if [ `pwd` != $m_path ]; then
	rm plot_depth.m 2>>$log
fi


rm $depth0 2>>$log

exit 0 

